<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>用户信息编辑 <small>认真阅读，谨慎操作！</small></h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <br>
                <form id="editUserForm" th:action="@{/user/edit}" data-parsley-validate=""
                      class="form-horizontal form-label-left" onsubmit="return false;">
                    <input type="hidden" name="id" th:value="${user.getId()}">
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="userName">用户名<span
                                class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="text" id="userName" name="username" readonly th:value="${user.getUsername()}"
                                   required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="trueName">真实姓名<span
                                class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input type="text" id="trueName" name="trueName" th:value="${user.getTrueName()}"
                                   required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">出生年月<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <div class='input-group date' id='myDatepicker'>
                                <input type='text' class="form-control" name="birthday"
                                       th:value="${user.getBirthday()}"/>
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                 </span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="middle-name" class="control-label col-md-3 col-sm-3 col-xs-12">登录密码<span
                                class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="middle-name" class="form-control col-md-7 col-xs-12" type="password"
                                   th:value="${user.getPwd()}" name="pwd">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">性别<span
                                class="required">*</span></label>
                        <div class="col-md-3 col-sm-3 col-xs-12">
                            <select class="form-control" name="sex">
                                <option value="1" th:selected="${user.getSex()} eq 1 ? 'true' : 'false'">男</option>
                                <option value="2" th:selected="${user.getSex()} eq 2 ? 'true' : 'false'">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="ln_solid"></div>
                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                            <button class="btn btn-primary" type="button" onclick="$c.dialogClose(userEditDialog)">取消
                            </button>
                            <button type="button" class="btn btn-success" id="editUserBut">提交</button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
</div>
<script>
    $('#myDatepicker').datetimepicker({
        format: 'YYYY/MM/DD',
    });
    $('#editUserBut').on('click', function () {
        $c.ajax({
            form: $('#editUserForm'),
            success: function (d) {
                $c.notify(d.msg);
                if (d.code == 200) {
                    $c.dialogClose(userEditDialog);
                    userTable.DataTable().ajax.reload();
                }
            }
        })
    })
</script>
</html>
